#include "fsl_common.h"
#include "fsl_iomuxc.h"
#include "MCIMX6Y2.h"

#include "bsp_delay.h"
#include "bsp_led.h"
#include "bsp_key.h"
#include "bsp_clk.h"
#include "bsp_beep.h"
#include "bsp_int.h"
#include "bsp_gpio.h"
 #include "bsp_gpt.h"
#include "bsp_uart.h"
#include "bsp_lcd.h"
#include "bsp_rtc.h"

int main() 
{
    int_init();
    imx6ull_clock_init();
    clk_Init(); 
    led_Init();
    key_init();
    beep_init();
    Delay_Init();
    UART_Init(UART1,115200);
    
    //////////RTC/////////////
    rtc_init();
    struct rtc_datetime rtcdate;
    // rtcdate.year = 2024;
   	// rtcdate.month = 10;
    // rtcdate.day = 3;
    // rtcdate.hour = 16;
    // rtcdate.minute = 40;
    // rtcdate.second = 0;
	// rtc_setdatetime(&rtcdate); /* 初始化时间和日期 */
    while(1)					
	{	
		rtc_getdatetime(&rtcdate);
		printf("%d/%d/%d %d:%d:%d\r\n",rtcdate.year, rtcdate.month, rtcdate.day, rtcdate.hour, rtcdate.minute, rtcdate.second);
		Delay_ms(1000);	/* 延时一秒 */
	}

    //////////LCD/////////////
    LCD_Init();
    LCD_Enable();
    while (1)
    {
        LCD_Fill(RGB(191,25,27));
        Delay_ms(100);
        LCD_Fill(RGB(35,217,110));
        Delay_ms(100);
    }
    //////////按键测试//////////////
    key_int_init();
    extern uint8_t key_flag;
    while(1)
    {
        static i;
        printf("这是printf测试代码：%d\r\n",i++);
        led_toggle();
        if(key_flag==1)
            beep_toggle();
        else
            beep_OFF();
        
        Delay_ms(500);
    }

    return 0;
}
